module WWW
  class Tkd
    class Gold
      class Service
        class User
          #更新用户登录次数
          def self.update_login_liveness user
            if user.last_liveness_at==nil
              user.last_liveness_at=Time.now
              user.login_count=1
            else
              last_liveness_at = user.last_liveness_at.strftime("%Y-%m-%d %H:%M:%S")
              user.login_count = user.login_count+1
              if ( Time.now-Time.parse(last_liveness_at))>20*24*60*60
                user.last_liveness_at=Time.now
                user.login_count=1
              end
            end
            user.save
          end
        end
      end
    end
  end
end
